package data

import (
	"context"
	"time"
	"verify-code/internal/biz"

	"github.com/go-kratos/kratos/v2/log"
)

//customer中与数据操作相关的代码

type customerData struct {
	data *Data
	log  *log.Helper
}

// NewCustomerData New方法
func NewCustomerData(data *Data, logger log.Logger) biz.CustomerData {
	return &customerData{data: data, log: log.NewHelper(logger)}
}

// 设置验证码的方法
func (data customerData) SetVerifyCode(ctx context.Context, telephone, code string, ex int) error {
	const life = 60
	status := data.data.Rdb.Set(context.Background(), "CVC:"+telephone, code, time.Duration(ex)*time.Second)
	if _, err := status.Result(); err != nil {
		return err
	}
	return nil
}

// 设置验证码
